<template>
  <div class="hd-nav" 
  :style="[{background:(state?'#fff':'')},{color:(state?'#333':'#fff')}]">
    <!-- 导航 -->
    <i @click="goback" class="iconfont icon-xiangzuo1 icon-1"></i>
    <slot name="text"></slot>
    <i class="iconfont icon-fenxiang icon-2" @click="showShare = true"></i>
    <van-share-sheet
      v-model="showShare"
      title="立即分享给好友"
      :options="options"
      @select="onSelect"
    />
  </div>
</template>
<script>
import { ShareSheet, Toast } from "vant";
export default {
  name: "mySearch",
  props: {
    state: {
      type: Boolean,
      default:false
    },
  },
  data() {
    return {
      showShare: false,
      options: [
        { name: "微信", icon: "wechat" },
        { name: "微博", icon: "weibo" },
        { name: "复制链接", icon: "link" },
        { name: "分享海报", icon: "poster" },
      ],
    };
  },
  components: {
    [ShareSheet.name]: ShareSheet,
    [Toast.name]: Toast,
  },
  methods: {
    goback() {
      this.$router.go(-1);
    },
    onSelect(option) {
      Toast(option.name);
      this.showShare = false;
    },
  },
};
</script>

<style lang="scss" scoped>
.hd-nav {
  width: 100%;
  height: 44px;
  // background: #ccc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 99;
  transition: all .3s ease;
  .icon-1 {
    font-size: 30px;
    margin-left: 10px;
    // color: #;
  }
  .icon-2 {
    font-size: 30px;
    margin-right: 10px;
    // color: #;
    font-weight: bold;
  }
  p {
    line-height: 44px;
    text-align: center;
    font-size: 22px;
    // color: #;
    font-weight: bold;
  }
}
</style>